﻿@using Treca.Util;

@{
    string projectName = Tools.GetSection("AppConfig", "ProjectName");
    string code=(string)this.ViewData["code"];
    string appid=(string)this.ViewData["appid"];
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>@projectName</title>
    <!-- Tell the browser to be respodnsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!--bootstrap-->
    <link href="@Url.Scrpit("~/Scripts/vendor/bootstrap/css/bootstrap.min.css")" rel="stylesheet" />
    <!--awesome-->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/font-awesome.min.css")" rel="stylesheet" />
    <!-- Ionicons -->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/ionicons.min.css")" rel="stylesheet" />
    <!-- Theme style -->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/AdminLTE.min.css")" rel="stylesheet" />
    <!-- iCheck -->
    <link href="@Url.Scrpit("~/Scripts/vendor/iCheck/square/blue.css")" rel="stylesheet">

    <link href='@Url.Content("~/css/fx/login.css")' rel="stylesheet" />

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
    .telTop{ margin-top: 160px; }
</style>
</head>
<body class="hold-transition login-page" style="height:80%">
    @*<div class="login-logo" >
            <img src="../Images/logo.png"  height="60%"/>

        <b>@ViewBag.ProjectLogin</b>
        </div>*@
    <div class="login-box telTop" id="loginwindiv">
        <div class="login-logo">
            
            <p style="color:white"><b>包钢清洁化运输</b></p>
            <p style="color:white"><b>门禁预约平台</b></p>
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            @*<p class="login-box-msg">Sign in to start your session</p>*@
            <form id="form" role="form">
                <h3 class="no-margin">登录：<button type="button" class="btn btn-primary" style="float: right; margin-bottom: 5px; opacity: 0.8" onclick="javascript:window.location.href='/CleanBG/cbg_register/FormPwdRecv'">忘记密码</button></h3>
                <input style="display:none" id="code" name="code" type="text" value="@code" class="form-control uname"  placeholder="请输入账号">
                 <input style="display:none" id="appid" name="appid" type="text" value="@appid" class="form-control uname"  placeholder="请输入账号">
                <div class="form-group has-feedback">
                    <input id="userName" name="userName" type="text" class="form-control uname" required placeholder="请输入账号">
                    <!--
                     <span class="glyphicon glyphicon-user form-control-feedback"></span>
                     -->
                    <div class="help-block with-errors"></div>
                </div>
                <div class="form-group has-feedback">
                    <input id="password" name="password" type="text" required class="form-control pword m-b" placeholder="请输入密码">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    <div class="help-block with-errors"></div>
                </div>
                <div class="row">
                    <div class="col-xs-4">
                        <div class="checkbox icheck">
                            <input type="checkbox" id="savePwd"><label style="padding-left:5px" for="savePwd">记住密码</label>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <div>
                            <button type="button" class="btn btn-primary" style="opacity:0.8" onclick="javascript:window.location.href='/CleanBG/cbg_register/FormReg'">司机注册</button>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-xs-2">
                        <button type="submit" class="btn btn-primary">登录</button>
                        <wx-open-launch-weapp
                          id="launch-btn"
                          username="gh_7890ac633804"
                          path="pages/login/login"
                        >
                          <script type="text/wxtag-template">
                            <style>.btn { padding: 12px }</style>
                            <button class="btn">打开小程序</button>
                          </script>
                        </wx-open-launch-weapp>
                        <script>
                        document.addEventListener('WeixinOpenTagsError', function (e) {
                          alert(e.detail.errMsg); // 无法使用开放标签的错误原因，需回退兼容。仅无法使用开发标签，JS-SDK其他功能不受影响
                        });
                          var btn = document.getElementById('launch-btn');
                          btn.addEventListener('launch', function (e) {
                            console.log('success');
                          });
                          btn.addEventListener('error', function (e) {
                            console.log('fail', e.detail);
                          });
                        </script>
                    </div>
                    <!-- /.col -->
                </div>

            </form>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <!-- jQuery 2.2.3 -->
    <script src="@Url.Scrpit("~/Scripts/vendor/jQuery/jquery-2.2.3.min.js")"></script>

    <!--jQuery-cookie-->
    <script src="@Url.Scrpit("~/Scripts/vendor/jQuery-cookie/jquery.cookie.min.js")"></script>

    <!-- iCheck -->
    <script src="@Url.Scrpit("~/Scripts/vendor/iCheck/icheck.min.js")"></script>
    <!--bootstrap-->
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap/js/bootstrap.min.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap/js/bootstrap-BtnBuilder.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap-validator/validator.min.js")"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <!--layer-->
    <script src="@Url.Scrpit("~/Scripts/vendor/layer/layer.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/layer/layer-extends.js")"></script>

    <!--bootstrapPwdBox-->
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap-pwdbox/bootstrapPwdBox.js")"></script>

    <!--fx-->
    <script src="@Url.Scrpit("~/Scripts/util/util.js")"></script>

    <script>
        var rootUrl = '@Url.Content("~/")';

        $(function () {
            backgrund();
            //alert(location.href.split('#')[0])
            $.getJSON(rootUrl + 'PushMessage/MessageApi/JsSdkSignature?appId=@appid&url='+encodeURIComponent(location.href)+'',null, function (resJson) {
                        loading(false);
                        if (resJson.Success) {
                             wx.config({
                                 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印
                                 appId: '@appid', // 必填，公众号的唯一标识
                              timestamp: resJson.Data.timestamp, // 必填，生成签名的时间戳
                              nonceStr: resJson.Data.nonceStr, // 必填，生成签名的随机串
                              signature: resJson.Data.signature,// 必填，签名
                              jsApiList: [], // 必填，需要使用的JS接口列表
                              openTagList: ['wx-open-launch-app'] // 可选，需要使用的开放标签列表，例如['wx-open-launch-app']
                            });
                        }
                        else {
                            dialogError(resJson.Msg);
                        }
           });
            wx.ready(function () {
              // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中
            });
            wx.error(function (res) {
              // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名
            });
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' // optional
            });

            //表单校验
            $('#form').validator().on('submit', function (e) {
                //校验成功
                if (!e.isDefaultPrevented()) {
                    e.preventDefault();

                    var values = $('#form').getValues();
                    //保存账号密码
                    var checked = $('#savePwd')[0].checked;
                    savePwd(values.userName, values.password, checked);
                    loading();
                    $.getJSON(rootUrl + 'PushMessage/MessageApi/SubmitLogin',values, function (resJson) {
                        loading(false);

                        if (resJson.Success) {
                            dialogSuccess(resJson.Msg);
                        }
                        else {
                            dialogError(resJson.Msg);
                        }
                    });
                }
            })


            var system = {
                win: false,
                mac: false,
                xll: false,
                ipad: false
            };
            //检测平台
            var p = navigator.platform;
            system.win = p.indexOf("Win") == 0;
            system.mac = p.indexOf("Mac") == 0;
            system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
            system.ipad = (navigator.userAgent.match(/iPad/i) != null) ? true : false;
            //跳转语句，如果是手机访问就自动跳转到wap.baidu.com页面
            if (system.win || system.mac || system.xll || system.ipad) {



                $("#loginwindiv").removeClass("telTop");
            } else {


               // alert("手机")
            }


        });

        //背景图切换
        function backgrund() {
            var i = Math.floor(Math.random() * 4) + 1;
            console.log(i);
            var url = "url('/Images/login_bg_" + i + ".jpg')";
            console.log(url);
            $(".login-page").css("background", url + "no-repeat center").css("background-size", "1920px 1080px")
        }
        //设置保存的账号密码
        function setPwd() {
            var userName = $.cookie('userName');
            var password = $.cookie('password');
            if (userName && password) {
                $('#userName').val(userName);
                $('#savePwd').prop('checked', 'checked');
            } else {
                $('#savePwd').removeAttr('checked');
            }

            $('#password').bootstrapPwdBox({
                value: password
            });
        }

        //保存账号密码
        function savePwd(userName, password, isSave) {
            if (isSave) {
                $.cookie('userName', userName, {
                    expires: new Date('9999/1/1'),
                    path: '/'
                });
                $.cookie('password', password, {
                    expires: new Date('9999/1/1'),
                    path: '/'
                });
            } else {
                $.removeCookie('userName', { path: '/' });
                $.removeCookie('password', { path: '/' });
            }
        }
    </script>
</body>
</html>
